const My = {
  // 更新个人资料的sql语句
  updateMyMsg(option) {
    // option = JSON.stringify(option)
    let user_name = JSON.stringify(option.user_name)
    let user_sex = JSON.stringify(option.user_sex)
    let user_birthday = JSON.stringify(option.user_birthday)
    let user_describe = JSON.stringify(option.user_describe)
    return `UPDATE user set user_name=${user_name},user_sex=${user_sex},user_birthday=${user_birthday},user_describe=${user_describe} WHERE user_phone=${option.tel}`
  },
  // 查询更新后的sql语句
  selectMy(option) {
    return `select * from user where user_phone=${option.tel}`
  },

  // 更新头像的sqp语句
  updateMyHead(option) {
    let user_photo = JSON.stringify(option.imgUrl)
    return `UPDATE user set user_photo=${user_photo} WHERE user_phone=${option.tel}`
  },

  // 获取picker值的sql语句
  getPicker(option) {
    return `select * from list`
  },

  // 查询picker的id
  getPickerId(option) {
    let options = JSON.stringify(option)
    return `select topic_id from list where text=${options}`
  },

  //上传商品的代码
  insertShops(option) {
    let id = JSON.stringify(option.shopId)
    let phone = JSON.stringify(option.tel)
    let shopName = JSON.stringify(option.title)
    let price = JSON.stringify(option.price)
    let left = JSON.stringify(option.left)
    let des = JSON.stringify(option.des)
    let pic = JSON.stringify(option.pic)
    return `INSERT INTO list_information
    ( good_topic_id, good_user_phone, shopName, price, monthNum, good_describe, shopImgUrl) 
    VALUES (${option.shopId},${phone},${shopName},${price},${left},${des},${pic});`
  },

  // 检查是否进行校园认证：是否存在改用户信息
  isCheckPersion(option) {
    return `select * from student where student_number=${option.usernumber}`
  },

  // 更新校园认证消息
  updateUserInfo(option) {
    return `update student set student_attesation=1 where student_phone=${option.tel}`
  },

  // 校验该用户是否认证
  isCheckSuccess(option) {
    return `select * from student where student_phone=${option.tel}`
  },

  // 查询用户地址列表
  getAddressList(option) {
    return `SELECT address_id,address_name,address_tel,address_address,address_postalcode,address_isDefault from  address,user  where user_id =address_user_id and user_phone=${option.tel}`
  },

  //查询该用户的id号
  getUserId(option) {
    return `select user_id from user where user_phone =${option.tel}`
  },

  // 添加用户地址
  addUserAddress(option) {
    console.log(option)
    let name = JSON.stringify(option.name)
    let tel = JSON.stringify(option.tel)
    let postalCode = JSON.stringify(option.postalCode)
    let address = JSON.stringify(option.address)
    return `insert into address(address_user_id,address_name,address_tel,address_postalcode,address_address,address_isDefault) values(${option.user_id},${name},${tel},${postalCode},${address},${option.isDefault})`
  },

  // 查询用的存在默认的地址的id
  selectDefaultAddress(option) {
    return `select address_id,address_isDefault from address where address_isDefault=true and address_user_id=${option}`
  },

  // 更新用户的address默认地址
  updateDefaultAddress(option) {
    return `update address set address_isDefault=false where address_id=${option}`
  },

  // 插入反馈数据库
  insertFeedback(option) {
    return `insert into feedback(feedback_content) values('${option.content}')`
  },

  // 查找反馈id
  selectFeedbackId(option) {
    return `select feedback_id from feedback where feedback_content='${option.content}'`
  },

  // 反馈数据库插入图片
  insertFeedbackSrc(img, id) {
    console.log(img, id)
    return `insert into feedback_src(feedback_src_src,feedback_src_content_id) values('${img}','${id}')`
  },

  // 查找id
  selectShopUpload(option) {
    return `select good_id from list_information where good_describe='${option}'`
  },

  // 上传商品插入图片
  insertListSrc(img, id) {
    console.log(img, id)
    return `insert into list_src(pic_src,pic_list_id) values('${img}','${id}')`
  },

  // 查询在线商品
  selectOnlineData(tel) {
    return ` select * from list_information where good_user_phone=${tel}`
  },

  // 删除下架商品的外键
  delForeignKey(id) {
    return `delete from list_src where pic_list_id=${id}`
  },

  // 杀出下架商品的主键
  delKey(id) {
    return `delete from list_information where good_id=${id}`
  },

  selectAtten(tokenObj) {
    console.log(tokenObj)
    return `select * from student where student_phone=${tokenObj.tel}`
  },

  // 查询用户id
  selectUserId(tokenObj) {
    return `select user_id from  user where user_phone=${tokenObj.tel}`
  },

  // 查询用户订单数量
  selectOrderNum(id) {
    return `select * from ordernumber where ordernumber_user_id=${id} and ordernumber_status=0`
  },

  // 查询用户订单数量
  selectOrderPayNum(id) {
    return `select * from ordernumber where ordernumber_user_id=${id} and ordernumber_status=3`
  },
}

exports = module.exports = My
